<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>写邮件</title>
	
	<link href="/oas/css/style.css" rel="stylesheet" type="text/css" />
	<style type="text/css" >
		.mySpan {color:red;}
		.action .pages .tdName {text-align:right;}
		table{border-collapse:separate;}
		textarea{width:456px; height:52px; border:1px #797979 solid;}
	</style>
	
	<script type="text/javascript">
		function checkSubmit()
		{
			var title = document.getElementById("mailTitle").value;
			var attachment = document.getElementById("attachment");
			var size = "0";
			var maxSize=9*1024*1024;
			attachment.size=maxSize;
			if(title == null || title == "")
			{
				alert("邮件标题不能为空!");
				return false;
			}
			try
			{
				for(var i=0;i<attachment.files.length;i++)
				{
				size=size+attachment.files[i].size;
				}
			}
			catch(err)
			{
				alert("计算附件总大小出现异常："+err.message);
			}
			if(size>maxSize)
			{
				alert("附件大小不能超过9M！");
				return false;
			}
			else
			{
				return true;
			}
			
		}
	</script>
</head>
<body>
	<div class="action">
		<div class="t">
			写邮件
		</div>
		<div class="pages">
			<form onSubmit="return checkSubmit()" action="/oas/email/sendEmail" method="post" enctype="multipart/form-data">
				<table>
					<tr>
						<td class="tdName">收件人：</td>
						<td>
							<select name="workNo">
							<s:iterator value="#request.users" status="uStatus" id="user">
								<option value="<s:property value='#user.workNo'/>"><s:property value="#user.username"/></option>
							</s:iterator>
							</select>
						</td>
					</tr>
					<tr>
						<td class="tdName">邮件标题：</td>
						<td>
							<input type="text" name="title"/><span class="mySpan">*</span>
						</td>
					</tr>
					<tr>
						<td class="tdName">邮件内容：</td>
						<td>
							<textarea name="details"></textarea>
						</td>
					</tr>
					<tr>
						<td class="tdName">上传附件：</td>
						<td>
							<input type="file" name="attachment" id="attachment"/><span class="mySpan">*</span>(上传附件不能大于9M)
							<br/><span>这里只实现了上传一个附件的功能</span><br/>
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type="submit" value="发送邮件"/></td>
					</tr>
				</table>
				
			</form>	
		</div>
	</div>
</body>
</html>